﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeBigCommonUI.Common
{
    public class ObservableProperty<T> : INotifyPropertyChanged
    {
        public ObservableProperty(T value)
        {

        }

        public event PropertyChangedEventHandler PropertyChanged;

        private T LatestValue { get; set; }

        public T Value
        {
            get
            {
                return LatestValue;
            }

            set
            {
                if (EqualityComparer<T>.Default.Equals(LatestValue, value))
                    return;

                LatestValue = value;

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
            }
        }
    }
}
